//
//  ShowAllHeadView.m
//  ImGuider
//
//  Created by 李陆涛 on 2017/12/26.
//  Copyright © 2017年 imguider. All rights reserved.
//

#import "ShowAllHeadView.h"

@interface ShowAllHeadView ()
@property (nonatomic, strong) UILabel *mainLabel;
@property (nonatomic, strong) UILabel *detailLabel;

@end

@implementation ShowAllHeadView

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    
    self.mainLabel = [[UILabel alloc] initWithFrame:self.frame];
    self.mainLabel.textColor = kTitleColor;
    self.mainLabel.font = Font(22);
    self.mainLabel.text = MYLocalizedString(@"HOME_HOT_RECORD", nil);
    [self addSubview:self.mainLabel];
    [self.mainLabel sizeToFit];
    [self.mainLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self.mas_centerY).offset(5);
        make.left.equalTo(self).offset(16);
        
    }];
    
    
    UIImageView *rightImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"rightarrow"]];
    
    [self addSubview:rightImageView];
    
    [rightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.equalTo(self).offset(-16);
        make.centerY.equalTo(self.mas_centerY).offset(5);
    }];
    
    self.detailLabel = [[UILabel alloc] init];
    self.detailLabel.textColor = kContentColor;
    self.detailLabel.font = Font(14);
    self.detailLabel.text = MYLocalizedString(@"PUBLIC_SHOW_ALL", nil);
    [self addSubview:self.detailLabel];
    [self.detailLabel sizeToFit];
    
    [self.detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self.mas_centerY).offset(5);
        make.right.equalTo(rightImageView.mas_left).offset(-5);
    }];
    
    [self addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showAllAction)]];
    
    // 1 热门讲解；2 热门目的地；3 最新专题;4 热门行家
}

- (void)setType:(HomeCellType)type {
    
    _type = type;
    
    
    switch (type) {
        case HomeCellTypeLine: {
            self.mainLabel.text = MYLocalizedString(@"HOME_HOT_RECORD", nil);
            self.detailLabel.text = MYLocalizedString(@"PUBLIC_SHOW_ALL", nil);
        }
            break;
        case HomeCellTypeDestination: {
            self.mainLabel.text = MYLocalizedString(@"HOME_HOT_DESTINATION", nil);
            self.detailLabel.text = MYLocalizedString(@"PUBLIC_SHOW_ALL", nil);
        }
            break;
        case HomeCellTypeSpecial: {
            self.mainLabel.text = MYLocalizedString(@"HOME_HOT_THEME", nil);
            self.detailLabel.text = MYLocalizedString(@"PUBLIC_SHOW_ALL", nil);
        }
            break;
        case HomeCellTypeGuider: {
            
            self.mainLabel.text = MYLocalizedString(@"HOME_HOT_EXPERT", nil);
            self.detailLabel.text = MYLocalizedString(@"PUBLIC_SHOW_ALL", nil);
        }
            break;
        case HomeCellTypeScenic: {
            
            self.mainLabel.text = MYLocalizedString(@"HOME_HOT_ATTRACTION", nil);
            self.detailLabel.text = MYLocalizedString(@"PUBLIC_SHOW_ALL", nil);
        }
            break;
        case HomeCellTypeTiket: {
            
            self.mainLabel.text = MYLocalizedString(@"HOME_HOT_TICKET", nil);
            self.detailLabel.text = MYLocalizedString(@"PUBLIC_SHOW_ALL", nil);
        }
            break;
        case CityCellTypeNear: {
            
            self.mainLabel.text = MYLocalizedString(@"HOMEPAGE_BUSINESS", nil);
            self.detailLabel.text = MYLocalizedString(@"PUBLIC_SHOW_ALL", nil);
        }
            break;
        default:
            break;
    }
}

- (void)showAllAction {
    
    if ([_delegate respondsToSelector:@selector(showAllAction:)]) {
        [_delegate showAllAction:self];
    }
}


+ (ShowAllHeadView *)getHeadViewWithTableView:(UITableView *)tableView {
    
    ShowAllHeadView * headView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"ShowAllHeadView"];
    
    if (!headView) {
        headView = [[ShowAllHeadView alloc] initWithReuseIdentifier:@"ShowAllHeadView"];
    }
    
    return headView;
}

@end

